/*
 * Copyright (c) 2018, apexes.net. All rights reserved.
 *
 *         http://www.apexes.net
 *
 */
package net.apexes.demo.codegen.entity.base;

import com.j256.ormlite.field.DatabaseField;
import net.apexes.demo.codegen.entity.enums.StatusFlag;

import java.util.Date;
import java.util.Objects;

/**
 * 
 * @author <a href="mailto:hedyn@foxmail.com">HeDYn</a>
 *
 */
public abstract class OrmliteEntityBase implements java.io.Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    /**
     * 
     * @author <a href="mailto:hedyn@foxmail.com">HeDYn</a>
     *
     */
    protected interface $ {

        /**
         * uuid
         */
        String id = "ID";

        /**
         * STATUS_FLAG
         */
        String statusFlag = "STATUS_FLAG";

        /**
         * VERSION
         */
        String version = "VERSION";

        /**
         * CRT_WHO
         */
        String crtWho = "CRT_WHO";

        /**
         * CRT_TIME
         */
        String crtTime = "CRT_TIME";

        /**
         * UPD_WHO
         */
        String updWho = "UPD_WHO";

        /**
         * UPD_TIME
         */
        String updTime = "UPD_TIME";

    }

    @DatabaseField(columnName = $.id, id = true, canBeNull = false)
    private String id;

    @DatabaseField(columnName = $.statusFlag, canBeNull = false)
    private StatusFlag statusFlag;

    @DatabaseField(columnName = $.version, canBeNull = false)
    private String version;

    @DatabaseField(columnName = $.crtWho, canBeNull = false)
    private String crtWho;

    @DatabaseField(columnName = $.crtTime, canBeNull = false)
    private Date crtTime;

    @DatabaseField(columnName = $.updWho)
    private String updWho;

    @DatabaseField(columnName = $.updTime)
    private Date updTime;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public StatusFlag getStatusFlag() {
        return statusFlag;
    }

    public void setStatusFlag(StatusFlag statusFlag) {
        this.statusFlag = statusFlag;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getCrtWho() {
        return crtWho;
    }

    public void setCrtWho(String crtWho) {
        this.crtWho = crtWho;
    }

    public Date getCrtTime() {
        return crtTime;
    }

    public void setCrtTime(Date crtTime) {
        this.crtTime = crtTime;
    }

    public String getUpdWho() {
        return updWho;
    }

    public void setUpdWho(String updWho) {
        this.updWho = updWho;
    }

    public Date getUpdTime() {
        return updTime;
    }

    public void setUpdTime(Date updTime) {
        this.updTime = updTime;
    }

    @Override
    public String toString() {
        return getClass().getName() + ":" +
                "id=" + id +
                ",statusFlag=" + statusFlag +
                ",version=" + version +
                ",crtWho=" + crtWho +
                ",crtTime=" + crtTime +
                ",updWho=" + updWho +
                ",updTime=" + updTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        OrmliteEntityBase that = (OrmliteEntityBase) o;
        return Objects.equals(id, that.id);
    }

    @Override
    public int hashCode() {
        return id != null ? id.hashCode() : 0;
    }
}
